package fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.locateddevice;

import java.util.HashMap;

import fr.inria.diagen.core.ServiceConfiguration;
import fr.inria.diagen.core.exception.DiaGenException;
import fr.inria.diagen.core.exception.InvocationException;
import fr.inria.diagen.core.network.RemoteServiceInfo;
import fr.inria.diagen.core.service.local.Service;

import fr.inria.phoenix.scenario.bwsnfirefighting.framework.datatype.Location;

import fr.inria.diagen.core.module.command.ICommandListener;

/**
 * It can be extended by the other devices to gain location information
 *
 * @[28,0]
 * device LocatedDevice {
 *   attribute location as Location;
 * }
 */
public abstract class LocatedDevice extends Service implements ICommandListener {

  /**
     * @param serviceConfiguration
     */
    public LocatedDevice(ServiceConfiguration serviceConfiguration , fr.inria.phoenix.scenario.bwsnfirefighting.framework.datatype.Location location) {
      super("LocatedDevice", serviceConfiguration, GeneratedFramework.getInstance());
      setLocation(location);
    }

    @Override
    public final HashMap<String, Object> getAttributes() {
        HashMap<String, Object> attributes = new HashMap<String, Object>();
    
        attributes.put("location",location);

        return attributes;
    }
    
    private fr.inria.phoenix.scenario.bwsnfirefighting.framework.datatype.Location location;

    /**
     * @[29,11]
     * attribute location as Location;
     * @param newLocationValue
     */
    protected void setLocation(fr.inria.phoenix.scenario.bwsnfirefighting.framework.datatype.Location newLocationValue) {
      if (location != newLocationValue) {
        location = newLocationValue;
        updateAttributes();
      }
    }

    /**
     * @[29,11]
     * attribute location as Location;
     * @return
     */  
    public fr.inria.phoenix.scenario.bwsnfirefighting.framework.datatype.Location getLocation() {
      return location;
    }

	protected final void _postInitialize() {postInitialize();}
	
	/**
	 *
	 */
	protected void postInitialize() {}

  
    public final Object commandReceived(RemoteServiceInfo rsi, String methodName, Object... args) throws DiaGenException {
    
      throw new InvocationException("Undefined method name " + methodName);
    }
  
 
}